package com.mindcraft.shop.client;

import com.mindcraft.user.po.McUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author Mr.M
 * @version 1.0
 * @description TODO
 * @date 2023/2/22 14:50
 */
@Slf4j
@Component
public class UserServiceClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public McUser getUser(String userId) {
                log.error("查询用户发生熔断,用户id:{},熔断异常:{}",userId,throwable.toString(),throwable);
                //走降级了返回 false
                return null;
            }
        };
    }
}
